package com.vt.admin.controller;

import com.vt.admin.api.dto.PositionTree;
import com.vt.admin.api.entity.SysPosition;
import com.vt.admin.service.SysPositionService;
import com.vt.common.core.util.R;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("position")
@AllArgsConstructor
public class PositionController {

    SysPositionService service;

    @GetMapping("tree")
    public R<PositionTree> tree(@RequestParam(defaultValue = "") String managerId) {
        return service.tree(managerId);
    }

    @GetMapping("{id}")
    public R<SysPosition> findOne(@PathVariable("id") String id){
        return service.findOne(id);
    }

    @PostMapping
    public R<Boolean> save(@RequestBody SysPosition t){
        return service.save(t);
    }
}
